package com.cll.mapper;

import com.github.pagehelper.Page;
import com.cll.annotation.AutoFill;
import com.cll.dto.EmployeePageQueryDTO;
import com.cll.entity.Employee;
import com.cll.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 新增员工
     * @param emplLoyee
     */
    @AutoFill(OperationType.INSERT)
    @Insert("INSERT INTO employee VALUES (NULL,#{name},#{username},#{password},#{phone},#{sex}," +
            "#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Employee emplLoyee);

    /**
     * 员工分页查询  查询所用数据  根据员工姓名条件查询
     * @param employeePageQueryDTO
     * @return
     */
    Page<Employee> page(EmployeePageQueryDTO employeePageQueryDTO);


    /**
     * 员工信息,状态修改
     * @param employee
     */
    @AutoFill(OperationType.UPDATE)
    void update(Employee employee);


    /**
     * 根据id查询员工
     * @param id
     * @return
     */
    @Select("select * from employee where id = #{id}")
    Employee findById(Long id);
}
